//
//  HYCollectionViewCellForT22.m
//  TTLestening
//
//  Created by dllo on 16/3/29.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "HYCollectionViewCellForT22.h"
#import "HYModelForRecommend.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface HYCollectionViewCellForT22 ()

@property (nonatomic, strong) UILabel *labelForReason;
@property (nonatomic, strong) UILabel *labelForName;
@property (nonatomic, strong) UIImageView *imageViewCenter;
@property (nonatomic, strong) UIImageView *imageViewLeft;
@property (nonatomic, strong) UIImageView *imageViewRight;
@property (nonatomic, strong) UIButton *buttonForPlay;
@end

@implementation HYCollectionViewCellForT22
#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self createSubViews];
    }
    
    return self;
}

#pragma mark - createSubViews
- (void)createSubViews {
    
    self.labelForReason = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForReason];
    self.labelForReason.textColor = [UIColor grayColor];
    self.labelForReason.textAlignment = 1;
    self.labelForReason.font = [UIFont systemFontOfSize:14];
    
    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    self.labelForName.textAlignment = 1;
    self.labelForName.font = [UIFont boldSystemFontOfSize:16];
    
    self.imageViewLeft = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewLeft];
    
    self.imageViewRight = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewRight];
    
    self.imageViewCenter = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewCenter];
    
    self.buttonForPlay = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.buttonForPlay setImage:[UIImage imageNamed:@"iconfont-bofang-3"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.buttonForPlay];
    [self.buttonForPlay addTarget:self action:@selector(addToPlay) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)addToPlay {
    
    NSLog(@"暂未实现");
}

#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.labelForReason.frame = CGRectMake(20, 40, self.contentView.frame.size.width - 40, 25);
    
    self.labelForName.frame = CGRectMake(20, 40 + 25 + 10, self.contentView.frame.size.width - 40, 30);
    
    self.imageViewLeft.frame = CGRectMake(30, 40 + 25 + 10 + 30 + 20 + 40, self.contentView.frame.size.width / 2 - 30, self.contentView.frame.size.width / 2 - 30);
    
    self.imageViewRight.frame = CGRectMake(self.contentView.frame.size.width / 2, 40 + 25 + 10 + 30 + 20 + 40, self.contentView.frame.size.width / 2 - 30, self.contentView.frame.size.width / 2 - 30);
    
    self.imageViewCenter.frame = CGRectMake(70, 40 + 25 + 10 + 30 + 20, self.contentView.frame.size.width - 140, self.contentView.frame.size.width - 140);
    
    self.buttonForPlay.frame = CGRectMake(0, 0, 50, 50);
    self.buttonForPlay.center = self.imageViewCenter.center;
    
    
}

- (void)passMoldel:(HYModelForRecommend *)model {
    
    self.labelForName.text = model.name;
    self.labelForReason.text = model.reason;
    
    [self.imageViewLeft sd_setImageWithURL:[NSURL URLWithString:model.smallPicUrls[1]] placeholderImage:[UIImage imageNamed:@"iconfont-jiazai"]];
    [self.imageViewRight sd_setImageWithURL:[NSURL URLWithString:model.smallPicUrls[2]] placeholderImage:[UIImage imageNamed:@"iconfont-jiazai"]];
    [self.imageViewCenter sd_setImageWithURL:[NSURL URLWithString:model.smallPicUrls[0]] placeholderImage:[UIImage imageNamed:@"iconfont-jiazai"]];
}






















@end
